home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Taifun / Taifun 099 (1989-05-15)(Ossowski, Stefan)(DE)(PD).zip / Taifun 099 (1989-05-15)(Ossowski, Stefan)(DE)(PD).adf / PCQ / Runtime / readchar.asm < prev    next >
Assembly Source File  |  1989-03-31  |  782b  |  36 lines

  1.  
  2. *    ReadChar.asm (of PCQ Pascal runtime library)
  3. *    Copyright (c) 1989 Patrick Quaid
  4.  
  5. *    This reads a character from a text file.
  6.  
  7.     SECTION    ONE
  8.  
  9.     XREF    _p%readonechar
  10.     XREF    _p%getthatchar
  11.     XREF    stdinbuffer
  12.     XREF    _p%readarbbuf
  13.  
  14.     XDEF    _p%readchar
  15. _p%readchar
  16.     move.l    a0,a1            ; move variable address
  17.     move.l    4(sp),a0        ; get the file record address
  18.     move.l    a0,d0
  19.     bne    readcharfile        ; if not stdin, go around
  20.     move.l    a1,-(sp)        ; save address
  21.     jsr    _p%readonechar        ; read a character
  22.     jsr    _p%getthatchar
  23.     move.l    (sp)+,a1        ; get address back
  24.     move.b    stdinbuffer,(a1)    ; store the char
  25.     rts
  26.  
  27. readcharfile:
  28.     tst.b    12(a0)            ; is it eof?
  29.     bne.s    1$            ; if so, skip all this
  30.     move.b    4(a0),d0        ; get the buffered char
  31.     move.b    d0,(a1)            ; store it
  32.     jsr    _p%readarbbuf        ; read next character
  33. 1$    rts
  34.  
  35.     END
  36.